<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>动态数字时钟</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Arial', sans-serif;
            background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
            min-height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            overflow: hidden;
        }

        .clock-container {
            text-align: center;
            padding: 40px;
            background: rgba(255, 255, 255, 0.1);
            backdrop-filter: blur(10px);
            border-radius: 20px;
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
            border: 1px solid rgba(255, 255, 255, 0.2);
            max-width: 90%;
            width: 100%;
        }

        .clock {
            font-size: 4rem;
            font-weight: bold;
            color: #ffffff;
            text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
            letter-spacing: 0.1em;
            display: inline-flex;
            align-items: center;
            white-space: nowrap;
        }

        .time-part {
            display: inline-block;
            min-width: 2.5ch;
            text-align: center;
            transition: transform 0.3s ease;
        }

        .time-part.changing {
            transform: scale(1.1);
        }

        .colon {
            margin: 0 0.2em;
            animation: blink 1s infinite;
        }

        @keyframes blink {
            0%, 100% { opacity: 1; }
            50% { opacity: 0.3; }
        }

        .date {
            margin-top: 20px;
            font-size: 1.2rem;
            color: rgba(255, 255, 255, 0.8);
        }

        .floating-shapes {
            position: absolute;
            width: 100%;
            height: 100%;
            overflow: hidden;
            z-index: -1;
        }

        .shape {
            position: absolute;
            background: rgba(255, 255, 255, 0.05);
            border-radius: 50%;
        }

        .shape:nth-child(1) {
            width: 80px;
            height: 80px;
            top: 10%;
            left: 10%;
            animation: float 20s infinite ease-in-out;
        }

        .shape:nth-child(2) {
            width: 120px;
            height: 120px;
            top: 70%;
            right: 10%;
            animation: float 25s infinite ease-in-out;
        }

        .shape:nth-child(3) {
            width: 60px;
            height: 60px;
            bottom: 10%;
            left: 20%;
            animation: float 30s infinite ease-in-out;
        }

        @keyframes float {
            0%, 100% { transform: translateY(0) rotate(0deg); }
            50% { transform: translateY(-20px) rotate(180deg); }
        }

        @media (max-width: 768px) {
            .clock {
                font-size: 3rem;
            }
            .time-part {
                min-width: 2ch;
            }
        }

        @media (max-width: 480px) {
            .clock {
                font-size: 2.5rem;
            }
            .clock-container {
                padding: 30px 20px;
            }
        }
    </style>
</head>
<body>
    <div class="floating-shapes">
        <div class="shape"></div>
        <div class="shape"></div>
        <div class="shape"></div>
    </div>

    <div class="clock-container">
        <div class="clock" id="clock">
            <span class="time-part" id="hours">00</span>
            <span class="colon">:</span>
            <span class="time-part" id="minutes">00</span>
            <span class="colon">:</span>
            <span class="time-part" id="seconds">00</span>
        </div>
        <div class="date" id="date"></div>
    </div>

    <script>
        function updateClock() {
            const now = new Date();
            const hours = String(now.getHours()).padStart(2, '0');
            const minutes = String(now.getMinutes()).padStart(2, '0');
            const seconds = String(now.getSeconds()).padStart(2, '0');

            // 更新时间显示
            updateTimePart('hours', hours);
            updateTimePart('minutes', minutes);
            updateTimePart('seconds', seconds);

            // 更新日期
            const options = { year: 'numeric', month: 'long', day: 'numeric', weekday: 'long' };
            const dateString = now.toLocaleDateString('zh-CN', options);
            document.getElementById('date').textContent = dateString;
        }

        function updateTimePart(id, value) {
            const element = document.getElementById(id);
            if (element.textContent !== value) {
                element.textContent = value;
                element.classList.add('changing');
                setTimeout(() => {
                    element.classList.remove('changing');
                }, 300);
            }
        }

        // 初始化时钟
        updateClock();

        // 每秒更新一次
        setInterval(updateClock, 1000);

        // 页面可见性变化时重新同步时间
        document.addEventListener('visibilitychange', () => {
            if (!document.hidden) {
                updateClock();
            }
        });
    </script>
</body>
</html>
